package lib.pacificapp.util;

import android.content.Context; 
import android.net.ConnectivityManager;
import android.net.NetworkInfo; 

public class Networker {
	
	 public static Networker load(Context context){
		 return new Networker(context);
	 }
	 public static final int TYPE_WIFI =1;
	 public static final int TYPE_3G=2;
	 public static final int TYPE_NULL=0;
	 public static boolean isMessage3g=false;
	 
	 public int status=0;
	 
	 
	 
	  /**  
	* 
	* @param activity 
	* @return 
	*/ 
	public Networker(Context context) { 
	ConnectivityManager connectivity = (ConnectivityManager) context 
	.getSystemService(Context.CONNECTIVITY_SERVICE); 
	if (connectivity == null) { 
		 
	} else { 
	NetworkInfo[] info = connectivity.getAllNetworkInfo(); 
	if (info != null) { 
	for (int i = 0; i < info.length; i++) { 
	   if (info[i].getState() == NetworkInfo.State.CONNECTED) { 
		   if(info[i].getType() == ConnectivityManager.TYPE_WIFI)
			    status=TYPE_WIFI;
		   else
			    status=TYPE_3G;
		   
		   return;
	   }
	} 
	} 
	} 
	   status=TYPE_NULL;
	} 

	 
}
